package com.shiguiwu.springboot3.agent;


import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.AdviceAdapter;

/**
 * @description:
 * @author: stone
 * @date: Created by 2023/12/2 13:27
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.dubbo.agent
 */
public class TimeStatisticsAdapter  extends AdviceAdapter {
    protected TimeStatisticsAdapter(int i, MethodVisitor methodVisitor, int i1, String s, String s1) {
        super(i, methodVisitor, i1, s, s1);
    }


    @Override
    protected void onMethodEnter() {
        // 进入函数时调用TimeStatistics的静态方法start
        super.visitMethodInsn(Opcodes.INVOKESTATIC, "com/shiguiwu/springboot3/agent/TimeStatistics", "start", "()V", false);
        super.onMethodEnter();
    }

    @Override
    protected void onMethodExit(int opcode) {
        // 退出函数时调用TimeStatistics的静态方法end
        super.onMethodExit(opcode);
        super.visitMethodInsn(Opcodes.INVOKESTATIC, "com/shiguiwu/springboot3/agent/TimeStatistics", "end", "()V", false);
    }
}
